<?php

class ProductsController extends Controller {
    
    public function actionIndex() {
        $products_criteria = new CDbCriteria;
        $products_criteria->condition = "products_is_active = '1'";
        $products_criteria->order = "products_input_datetime DESC";

        $products_pagination = new CPagination(site_products::model()->count($products_criteria));
        $products_pagination->pageSize = Yii::app()->params['productsPerPage'];
        $products_pagination->applyLimit($products_criteria);

        $products_model = site_products::model()->findAll($products_criteria);

        $this->render('index', array('products_model' => $products_model, 'products_pagination' => $products_pagination));
    }

    public function actionDetail() {
        $products_model = site_products::model()->findByPk($_GET['id']);

        $this->render('detail', array(
            'products_model' => $products_model,
        ));
    }

}
